# coding:utf-8
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from models import User
from sql_create import db_path_str


def select_fun(table_name):
    engine = create_engine(db_path_str)
    print("初始化数据库引擎")
    DBSession = sessionmaker(bind=engine)
    session = DBSession()
    print("创建session对象")
    table_data = session.query(table_name).all()
    print("查询")
    session.close()
    return table_data


if __name__ == "__main__":
    select_fun(User)
